local RSNG = RSNG
local AceOO = AceLibrary("AceOO-2.0")
local C = RSNG.Classes

local StatusBarInfo = AceOO.Class(C.FilteredStatusBarInfo, C.ItooltipInfo)

local default_red, default_green, default_blue
do
	local i = ManaBarColor[0]
	default_red = i.r
	default_green = i.g
	default_blue = i.b
end

function StatusBarInfo.prototype:GetDefaultText()
	return L["Power"]
end

function StatusBarInfo.prototype:GetDefaultTextFormat()
	return L["%d%%"]
end

function StatusBarInfo.prototype:GetDefaultColor()
	return default_red, default_green, default_blue
end

function StatusBarInfo.prototype:GetCount()
	local value, count = 0, 0
	for unit in RSNG:ApplyFilter(self.filter) do
		local v = UnitMana(unit) / UnitManaMax(unit)
		value = value + v
		count = count + 1
	end
	return 0, 100, value / count
end

RSNG:RegisterStatusBarInfo(L["Power Bar"], StatusBarInfo)
